package per.dj.testpro.entity.protocol;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.Data;
import per.dj.testpro.utils.CommonUtils;

import java.util.List;

@Data
public class Res_03 implements IMessageBody{

    //年月日时分秒（BCD[6]）
    private String systemDate;

    //Unix时间戳（DWord）
    private String systemTimestamp;

    public final byte[] WriteToBytes() {

        ByteBuf buff = Unpooled.buffer(10);

        try{
            String[] systemDate = getSystemDate().split("-");
            for(String systemDateByte:systemDate){
                buff.writeByte(Integer.valueOf(systemDateByte, 16));
            }

            List<String> lstSystemTimestamp = CommonUtils.spritString(getSystemTimestamp());
            for(String systemTimestampByte:lstSystemTimestamp){
               buff.writeByte(Integer.valueOf(systemTimestampByte,16));
            }
            return buff.array();
        }finally {
            if(buff != null){
                buff.release();
            }
        }
    }

    public final void ReadFromBytes(byte[] bytes) {

    }
}
